package com.mz.ozy.mvp.presenter;


import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.mvp.model.MeModel;
import com.mz.ozy.mvp.view.VerfiedContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class VerifiedPresenter extends BasePresenterImpl<VerfiedContract.View> implements VerfiedContract.Presenter {

    private MeModel mModel;


    public VerifiedPresenter() {
        mModel = new MeModel();
    }


    @Override
    public void onGetCode(Context context, String mobilePhone) {
        mModel.onGetCode(context, mobilePhone)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.onGetCodeSuccess(bean);
                    }
                });
    }

    @Override
    public void uploadHeader(Context context, String uname, String cardid, String code) {
        mModel.onGeUp(context, uname, cardid, code)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.uploadSuccess(bean);
                    }
                });
    }
}
